var uid = location.search.substr(location.search.indexOf('=') + 1)

var app = new Vue({
  el: '#adminInfo',
  data: {
    ulist: getAdminById()
  },
  methods: {
    editAdmin() {
      $.ajax({
        url: 'http://47.102.45.219:8080/Appoint/adminZoneServlet/editAdmin',
        data: $('#adminEditForm').serialize(),
        dataType: 'json',
        type: 'post',
        async: false,
        xhrFields: {
          withCredentials: true
        },
        success: function (data) {
          //alert(1)
          if (data.statu) {
            layer.msg('修改成功', {
              icon: 1,
              time: 1000
            });
            xadmin.close();
            xadmin.father_reload();
          } else {
            layer.msg('修改失败', {
              icon: 0,
              time: 1000
            });
          }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {

        }
      })
    }
  }
})

//通过id获取管理员信息
function getAdminById() {
  var alist
  $.ajax({
    url: 'http://47.102.45.219:8080/Appoint/adminZoneServlet/getAdminById',
    data: {
      id: uid
    },
    dataType: 'json',
    type: 'post',
    async: false,
    xhrFields: {
      withCredentials: true
    },
    success: function (data) {
      alist = data.data
    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {

    }
  })
  return alist
}